package  
{
	/**
	 * ...
	 * @author Bryan Keiren & Sander van Katwijk
	 */
	public class Vector2 
	{
		public var x:Number;
		public var y:Number;
		public function Vector2(a_X:Number, a_Y:Number) 
		{
			x = a_X;
			y = a_Y;
		}
		public function Set(a_Vector2:Vector2):void			{	x = a_Vector2.x;	y = a_Vector2.y;					}
		public function toString():String					{	return "[" + x + ", " + y + "]";						}
		
		public function equals(a_Vector2:Vector2):Boolean	{	return a_Vector2.x == x && a_Vector2.y == y;			}
		
		public function length():Number						{	return Math.sqrt(x * x + y * y);						}
		public function dist(a_Vector2:Vector2):Number		{	var dx:Number = x - a_Vector2.x;
																var dy:Number = y - a_Vector2.y;
																return Math.sqrt(dx * dx + dy * dy);					}
		public function distSq(a_Vector2:Vector2):Number	{	var dx:Number = x - a_Vector2.x;
																var dy:Number = y - a_Vector2.y;
																return dx * dx + dy * dy;								}
		
		// Vector math
		public function addV(a_Vector2:Vector2):Vector2		{	return new Vector2(x + a_Vector2.x, y + a_Vector2.y);	}
		public function subtractV(a_Vector2:Vector2):Vector2{	return new Vector2(x - a_Vector2.x, y - a_Vector2.y);	}
		public function divideV(a_Vector2:Vector2):Vector2	{	return new Vector2(x / a_Vector2.x, y / a_Vector2.y);	}
		public function multiplyV(a_Vector2:Vector2):Vector2{	return new Vector2(x * a_Vector2.x, y * a_Vector2.y);	}
		// Scalar math
		public function divideN(a_Number:Number):Vector2	{	var rN:Number = 1 / a_Number; return multiplyN(rN  );	}
		public function multiplyN(a_Number:Number):Vector2	{	return new Vector2(x * a_Number   , y * a_Number   );	}
	}
}